﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using MJM.CBD.Conn;

namespace MJM.SPP.AccesoDatos
{
    public class AccesoRedAD
    {
        public DataTable ListarAccesos(string fecha, int oficina)
        {
            SqlConnection conn = new SqlConnection(Cadena.GetCadenaPadron());
            SqlCommand cmd = new SqlCommand("sp_s_T_APP_USUCON_ListarV2", conn);
            cmd.CommandType = CommandType.StoredProcedure;
            DataTable dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(); 
            try
            {
                cmd.Parameters.Add(new SqlParameter("@vUSUCON_chFECACC", fecha));
                cmd.Parameters.Add(new SqlParameter("@vUSUCON_inOFIPER", oficina));
                cmd.Connection.Open();
                da.SelectCommand = cmd;
                da.Fill(dt);
                cmd.Connection.Close();
                cmd.Dispose();
                conn.Dispose();
            }
            catch(Exception ex)
            {
                cmd.Dispose();
                conn.Dispose();
            }
            return dt;
        }
    }
}
